<template>
  <div>
    <!-- 面包屑导航条 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/toOneList' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>发票管理</el-breadcrumb-item>
      <el-breadcrumb-item>发票申请发票</el-breadcrumb-item>
    </el-breadcrumb>


    <el-form ref="ruleForm" :model="invoice" label-width="80px">
      <el-form-item label="发票抬头：" label-width="100px">
        <el-input v-model="invoice.invoiceTitle" style="width: 220px" disabled></el-input>
      </el-form-item>
      <el-form-item label="税号：" label-width="100px">
        <el-input v-model="invoice.invoiceNum" style="width: 220px" disabled></el-input>
      </el-form-item>
      <el-form-item label="发票类型：" label-width="100px">
        <el-select v-model="invoice.invoiceType" clearable placeholder="请选择" disabled>
          <el-option  label="增值税普通发票" :value="0"></el-option>
          <el-option label="增值税专用" :value="1"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="税率：" label-width="100px">
        <el-input v-model="invoice.taxRate" style="width: 220px" disabled></el-input>
      </el-form-item>
      <el-form-item label="开票金额：" label-width="100px">
        <el-input v-model="invoice.amount" style="width: 220px" disabled></el-input>
      </el-form-item>
      <el-form-item label="发票内容；" label-width="100px">
        <el-input v-model="invoice.content" style="width: 220px" disabled></el-input>
      </el-form-item>
      <el-form-item label="收件人：" label-width="100px">
        <el-input v-model="invoice.receiver" style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="联系电话：" label-width="100px">
        <el-input v-model="invoice.tel" style="width: 220px"  ></el-input>
      </el-form-item>
      <el-form-item label="收货地址：" label-width="100px">
        <el-input v-model="invoice.revAddress" style="width: 220px"></el-input>
      </el-form-item>
      <el-form-item label="物流公司：" label-width="100px">
        <el-input v-model="invoice.logistics_cym" style="width: 220px"  disabled></el-input>
      </el-form-item>
      <el-form-item label="快递单号：" label-width="100px">
        <el-input v-model="invoice.logistics_code" style="width: 220px" disabled></el-input>
      </el-form-item>
    </el-form>

    <div>
      <el-button type="primary" @click="submit">保存</el-button>
      <el-button type="primary" @click="resetForm()">重置</el-button>
    </div>
  </div>
</template>

<script>
  export default {
    name: "billAdd",
    data() {
      return {
        invoice:{},
        loginUser:"",
        costomerId:"",
        linkmanId:"",
        invoiceprice:"",
        code:"",
      }
    },
    methods:{
      getcostomer:function (){//根据id查询当前客户
        let id=this.costomerId
        this.$http.post("/customer/getcostomer/"+id).then((res) => {

          this.invoice=res.data.result;

        });
      },
      getlinkman:function (){//根据状态进行订单查询
        let id=this.linkmanId;
        this.$http.post("/customer/getlinkman/"+id).then((res) => {
          this.invoice.receiver=res.data.result.name;
          this.invoice.tel=res.data.result.tel;
          this.invoice.revAddress=res.data.result.revAddress;
        });
      },
      submit:function (){//
        this.$http.post("/bil/saveinvoice/"+this.costomerId+"/"+this.code,this.invoice).then((res) => {
          if (res.data.success) {
            this.$message.success(res.data.message);
          } else {
            this.$message.error(res.data.message);
          }
        });
      },
      resetForm:function (){//重置

      },
    },
    mounted() {
      //获取当前登录用户
      let costomer=JSON.parse(sessionStorage.getItem("costomer")); //=JSON.parse()字符串转json对象 ，JSON。stringify（）对象转字符串
      this.loginUser=costomer.name;
      this.costomerId=costomer.id; //当前登录人id
      let linkman=JSON.parse(sessionStorage.getItem("linkman")); //=JSON.parse()字符串转json对象 ，JSON。stringify（）对象转字符串
      this.linkmanId=linkman.id;
      this.getcostomer();
      this.getlinkman();
      let  code1=this.$route.query.code; //路由获取值
      this.code=code1;
    }
  }
</script>

<style scoped>

</style>
